10 HOME
20 PRINT CHR$(4);"PR#3"
22 DIM B(20,80)
24 DIM C(1510)
26 DIM W(6,7)

28 X1=10:Y1=42:BB=0:B=0

30 ONERR GOTO 31

31 INVERSE:VTAB 1:HTAB 30:PRINT"MAZE GAME":VTAB 23:HTAB 1:PRINT"                                                                               ":VTAB 23:HTAB 1:INPUT"INPUT A NUMBER BETWEEN 1 TO 99999 : ";RR:NORMAL
32 IF RR<1 OR RR>99999 THEN 31

33 ONERR GOTO 34

34 HOME:INVERSE:VTAB 23:HTAB 1:PRINT" PLEASE INSERT A DATA DISK IN SLOT 6 DRIVE 2,THEN PRESS <SPC> TO BE CONTINUE. ":VTAB 23:HTAB 79:GET G$:VTAB 23:HTAB 79:PRINT G$:NORMAL

35 IF G$<>" " THEN 34

36 NORMAL:D2=1:GOSUB 15800


39 NORMAL:HOME:ONERR GOTO 22200


40 VTAB 10:HTAB 40:PRINT " "
45 VTAB 10:HTAB 40:PRINT "M"
50 INVERSE:VTAB 10:HTAB 42:PRINT "$":NORMAL
52 VTAB 20:HTAB 6:PRINT"Y":VTAB 20:HTAB 10:PRINT"I":VTAB 20:HTAB 15:PRINT"R - RUN":VTAB 20:HTAB 32:PRINT"S - SAVE MAZE":VTAB 20:HTAB 66:PRINT"DOLLAR :    0"
54 VTAB 21 :HTAB 5:PRINT"G H":VTAB 21:HTAB 9:PRINT"J K":VTAB 21:HTAB 15:PRINT"F - GAME":VTAB 21:HTAB 32:PRINT"L - LOAD MAZE":VTAB 21:HTAB 47:PRINT"X - CATALOG":VTAB 21:HTAB 66:PRINT"  STEP :    0"
56 VTAB 22 :HTAB 6:PRINT"B":VTAB 22:HTAB 10:PRINT"M":VTAB 22:HTAB 15:PRINT"Q - QUIT":VTAB 22:HTAB 32:PRINT"C - CLEAR SCN":VTAB 22:HTAB 66:PRINT"RESTEP :    0"

58 INVERSE:VTAB 23:HTAB 1:PRINT"                                                                               ":NORMAL
59 GOSUB 1200

60 R1=0:NO=0
62 VTAB 10:HTAB 40:PRINT"M":INVERSE:VTAB X1:HTAB Y1:PRINT "$":VTAB 23:HTAB 1:PRINT"COMMAND :                                                                     ":VTAB 23:HTAB 11:GET A$:GOSUB 60000:VTAB 23:HTAB 11:PRINT A$:NORMAL
65 IF A$="Q" THEN 7000

74 IF A$=CHR$(25) THEN X2=X1-1:Y2=Y1:GOSUB 48000
75 IF A$=CHR$(7) THEN X2=X1:Y2=Y1-1:GOSUB 48000
76 IF A$=CHR$(8) THEN X2=X1:Y2=Y1+1:GOSUB 48000
77 IF A$=CHR$(2) THEN X2=X1+1:Y2=Y1:GOSUB 48000

78 IF A$="I" THEN X2=X1-1:Y2=Y1:GOSUB 48100
80 IF A$="J" THEN X2=X1:Y2=Y1-1:GOSUB 48100
90 IF A$="K" THEN X2=X1:Y2=Y1+1:GOSUB 48100
95 IF A$="M" THEN X2=X1+1:Y2=Y1:GOSUB 48100

100 IF A$="Y" THEN X2=X1-1:Y2=Y1:GOSUB 48200
110 IF A$="G" THEN X2=X1:Y2=Y1-1:GOSUB 48200
120 IF A$="H" THEN X2=X1:Y2=Y1+1:GOSUB 48200
130 IF A$="B" THEN X2=X1+1:Y2=Y1:GOSUB 48200

160 IF A$="R" THEN 300

162 IF A$="F" THEN 30000


172 IF A$="S" THEN 15000
180 IF A$="L" THEN 15100
182 IF A$="C" THEN 15500
184 IF A$="X" THEN 15800


191 IF A$=CHR$(6) THEN 33000

200 GOTO 60

300 X4=10:Y4=40:I1=1:S1=0:H2=0
305 VTAB 20:HTAB 47:PRINT"           ":VTAB 21:HTAB 75:PRINT"   0":VTAB 22:HTAB 75:PRINT"   0"
310 IF B(10,40)=1 THEN B(10,40)=0:VTAB 10:HTAB 40:PRINT"M":BB=BB-1:GOSUB 1200

312 REM  

314 IF B(X4,Y4+1)=1 AND B(X4+1,Y4+1)=1 AND B(X4+1,Y4)=1 AND B(X4+1,Y4-1)=1 AND B(X4,Y4-1)=1 AND B(X4-1,Y4-1)=1 AND B(X4-1,Y4)=1 AND B(X4-1,Y4+1)=1 THEN INVERSE:VTAB 20:HTAB 47:PRINT"NO EXIT":NORMAL:GOTO 60


315 VTAB X4:HTAB Y4:PRINT"M"
320 X5=X4:Y5=Y4
330 IF B(X4+1,Y4-1)=0 THEN XX=X4+1:YY=Y4-1:Q=5:F1=1:GOTO 530
340 IF B(X4+1,Y4)=0 THEN XX=X4+1:YY=Y4:Q=4:F1=2:GOTO 530
350 IF B(X4+1,Y4+1)=0 THEN XX=X4+1:YY=Y4+1:Q=6:F1=3:GOTO 530
360 IF B(X4,Y4+1)=0 THEN XX=X4:YY=Y4+1:Q=3:F1=4:GOTO 530
370 IF B(X4-1,Y4+1)=0 THEN XX=X4-1:YY=Y4+1:Q=7:F1=5:GOTO 530
380 IF B(X4-1,Y4)=0 THEN XX=X4-1:YY=Y4:Q=2:F1=6:GOTO 530
390 IF B(X4-1,Y4-1)=0 THEN XX=X4-1:YY=Y4-1:Q=8:F1=7:GOTO 530
395 IF B(X4,Y4-1)=0 THEN XX=X4:YY=Y4-1:Q=1:F1=8:GOTO 530
400 I1=I1-1:IF I1<1 THEN I1=1
410 A7=C(I1):C(I1)=23:H2=H2+1:N1=22:N2=78:GOSUB 900
420 IF A7=1 THEN YY=Y4+1:XX=X4
430 IF A7=4 THEN XX=X4-1:YY=Y4
440 IF A7=3 THEN YY=Y4-1:XX=X4
450 IF A7=2 THEN XX=X4+1:YY=Y4
460 IF A7=5 THEN XX=X4-1:YY=Y4+1
470 IF A7=6 THEN XX=X4-1:YY=Y4-1
480 IF A7=7 THEN XX=X4+1:YY=Y4-1
490 IF A7=8 THEN XX=X4+1:YY=Y4+1
500 GOTO 550
530 IF B(XX,YY)=2 THEN XX=X4:YY=Y4:ON F1 GOTO 340,350,360,370,380,390,395,400
540 C(I1)=Q:I1=I1+1
550 VTAB X4:HTAB Y4:PRINT" ":B(XX,YY)=2 
560 IF XX>19 OR XX<1 OR YY>79 OR YY<1 THEN VTAB X5:HTAB Y5:PRINT" ":GOSUB 27000:S1=0:H2=0:GOTO 650
570 X4=XX:Y4=YY:VTAB X4:HTAB Y4:PRINT"M":VTAB X5:HTAB Y5:PRINT" "
575 IF XX=10 AND YY=40 THEN R1=R1+1 
577 IF R1>8 THEN R1=0:NO=1:INVERSE:VTAB 20:HTAB 47:PRINT"NO EXIT":NORMAL:GOTO 650
580 S1=S1+1:N1=21:N2=78
590 IF S1>9 THEN N2=N2-1
600 IF S1>99 THEN N2=N2-1
610 IF S1>999 THEN N2=N2-1
620 VTAB N1:HTAB N2: PRINT S1
640 GOTO 315

650 INVERSE:VTAB 23:HTAB 1:PRINT"              WAITING                       ":NORMAL

660 FOR I=0 TO 20
670 FOR J=0 TO 80
680 IF B(I,J)<>1 THEN B(I,J)=0
690 NEXT J
700 NEXT I
705 INVERSE:VTAB 23:HTAB 15:PRINT"        ":NORMAL
710 IF NO=1 THEN NO=0:GOTO 60
720 INVERSE:VTAB 20:HTAB 47:PRINT"SHORTCUT":NORMAL
730 X7=10:Y7=40:I2=1
740 IF C(I2)=5 THEN X8=X7+1:Y8=Y7-1
750 IF C(I2)=4 THEN X8=X7+1:Y8=Y7
760 IF C(I2)=6 THEN X8=X7+1:Y8=Y7+1
770 IF C(I2)=3 THEN X8=X7:Y8=Y7+1
780 IF C(I2)=7 THEN X8=X7-1:Y8=Y7+1
790 IF C(I2)=2 THEN X8=X7-1:Y8=Y7
792 IF C(I2)=8 THEN X8=X7-1:Y8=Y7-1 
794 IF C(I2)=1 THEN X8=X7:Y8=Y7-1
796 IF X8>19 OR X8<1 OR Y8>79 OR Y8<1 THEN VTAB X7:HTAB Y7:PRINT" ":VTAB 20:HTAB 47:PRINT"            ":GOTO 60
800 VTAB X8:HTAB Y8:PRINT"M":VTAB X7:HTAB Y7:PRINT" ":X7=X8:Y7=Y8
810 I2=I2+1
880 GOTO 740

900 IF H2>9 THEN N2=N2-1
910 IF H2>99 THEN N2=N2-1
920 IF H2>999 THEN N2=N2-1
930 VTAB N1:HTAB N2: PRINT H2
940 RETURN




1000 IF X2<1 THEN X2=19
1010 IF X2>19 THEN X2=1
1020 IF Y2<1 THEN Y2=79
1030 IF Y2>79 THEN Y2=1
1040 RETURN

1050 IF X2<1 THEN X2=18
1060 IF X2>18 THEN X2=1
1070 IF Y2<2 THEN Y2=78
1080 IF Y2>78 THEN Y2=2
1090 RETURN




1100 IF B(X1,Y1)=0 THEN BB=BB+1
1110 RETURN 

1150 IF B(X1,Y1)=1 THEN BB=BB-1
1160 RETURN

1200 IF BB<0 THEN BB=0
1210 IF BB<10 AND BB>-1 THEN NN1=78
1220 IF BB<100 AND BB>9 THEN NN1=77
1230 IF BB<1000 AND BB>99 THEN NN1=76
1240 IF BB<10000 AND BB>999 THEN NN1=75
1242 VTAB 20:HTAB 75:PRINT"    "
1260 VTAB 20:HTAB NN1:PRINT BB
1270 RETURN

1400 N1=21:N2=78
1410 IF S1>9 THEN N2=N2-1
1420 IF S1>99 THEN N2=N2-1
1430 IF S1>999 THEN N2=N2-1
1440 VTAB N1:HTAB N2: PRINT S1
1450 RETURN


1500 IF XP<1 THEN XP=1
1510 IF XP>19 THEN XP=19
1520 IF YP<1 THEN YP=1
1530 IF YP>79 THEN YP=79
1540 RETURN



7000 HOME:PRINT CHR$(4);"CATALOG"+",D1,S6":END


14900 BB=0

14902 FOR I=1 TO 19
14910 FOR J=1 TO 79
14920 IF B(I,J)=1 THEN VTAB I:HTAB J:PRINT"$":BB=BB+1
14922 IF B(I,J)=0 THEN VTAB I:HTAB J:PRINT" "
14930 NEXT J
14940 NEXT I

14942 GOSUB 1200

14950 RETURN




15000 INVERSE:VTAB 23:HTAB 1:PRINT"                                                 ":VTAB 23:HTAB 1:INPUT"FILENAME : ";F$:NORMAL
15005 INVERSE:VTAB 23:HTAB 50:PRINT"SAVING":NORMAL

15006 IF F$=CHR$(43) AND PA=1 THEN INVERSE:VTAB 23:HTAB 1:PRINT"COMMAND :                                        PUZZLE":NORMAL:RETURN

15007 IF F$=CHR$(43) THEN INVERSE:VTAB 23:HTAB 12:PRINT"                                                                    ":NORMAL:GOTO 60

15008 IF LEN(F$) > 24 THEN INVERSE:VTAB 23:HTAB 12:PRINT"                                                                    ":NORMAL:GOTO 15000


15010 REM 

15012 PRINT CHR$(4);"OPEN";F$
15020 PRINT CHR$(4);"WRITE";F$ 
15030 FOR I=1 TO 19
15040 FOR J=1 TO 79
15050 PRINT B(I,J)
15060 NEXT J
15070 NEXT I
15072 PRINT CHR$(4);"CLOSE";F$

15073 IF CC=1 THEN VTAB 20:HTAB 6:PRINT"Y":VTAB 20:HTAB 10:PRINT"I":VTAB 20:HTAB 15:PRINT"R - RUN":VTAB 20:HTAB 32:PRINT"S - SAVE MAZE":VTAB 20:HTAB 66:PRINT"DOLLAR : "
15074 IF CC=1 THEN VTAB 21:HTAB 5:PRINT"G H":VTAB 21:HTAB 9:PRINT"J K":VTAB 21:HTAB 15:PRINT"F - GAME":VTAB 21:HTAB 32:PRINT"L - LOAD MAZE":VTAB 21:HTAB 47:PRINT"X - CATALOG":VTAB 21:HTAB 66:PRINT"  STEP :    0"
15075 IF CC=1 THEN VTAB 22:HTAB 6:PRINT"B":VTAB 22:HTAB 10:PRINT"M":VTAB 22:HTAB 15:PRINT"Q - QUIT":VTAB 22:HTAB 32:PRINT"C - CLEAR SCN":VTAB 22:HTAB 66:PRINT"RESTEP :    0"
15076 IF CC=1 THEN CC=0:INVERSE:VTAB 23:HTAB 1:PRINT"COMMAND : C                                                                    ":VTAB 23:HTAB 50:PRINT"PUZZLE":NORMAL


15078 X9=10:Y9=40:V8=10:V9=38:G1=0:MA=0

15079 M(1)=1:M(2)=2:M(3)=3:M(4)=4:M(5)=5:M(6)=6:M(7)=7:M(8)=8

15080 T$="R  DR  D  DL  L  UL  U  UR "



15081 PRINT CHR$(4);"OPEN";F$+".INDEX"
15082 PRINT CHR$(4);"WRITE";F$+".INDEX"
15083 PRINT X1:PRINT Y1:PRINT X9:PRINT Y9:PRINT V8:PRINT V9:PRINT G1:PRINT M(1):PRINT M(2):PRINT M(3):PRINT M(4):PRINT M(5):PRINT M(6):PRINT M(7):PRINT M(8):PRINT T$:PRINT MA
15084 PRINT CHR$(4);"CLOSE";F$+".INDEX"

15086 PRINT CHR$(4);"OPEN";F$+".BITMAP"
15087 PRINT CHR$(4);"WRITE";F$+".BITMAP" 
15088 FOR I=1 TO 19
15089 FOR J=1 TO 79
15090 PRINT B(I,J);
15091 NEXT J
15092 PRINT
15093 NEXT I
15094 PRINT CHR$(4);"CLOSE";F$+".BITMAP"

15095 IF PA=1 THEN PA=0:INVERSE:VTAB 23:HTAB 1:PRINT"COMMAND :                                        PUZZLE":NORMAL:RETURN

15096 IF TM=1 THEN TM=0:RETURN

15098 INVERSE:VTAB 23:HTAB 12:PRINT"                                                                    ":NORMAL
15099 GOTO 60

15100 INVERSE:VTAB 23:HTAB 12:PRINT"                                                                    ":VTAB 23:HTAB 1:INPUT"FILENAME : ";F$:NORMAL
15105 INVERSE:VTAB 23:HTAB 50:PRINT"LOADING":NORMAL
15106 IF F$=CHR$(43) THEN INVERSE:VTAB 23:HTAB 12:PRINT"                                                                    ":NORMAL:GOTO 60

15108 REM 

15110 REM 
15120 PRINT CHR$(4);"READ";F$ 
15130 FOR I=1 TO 19
15140 FOR J=1 TO 79
15150 INPUT B(I,J)
15160 NEXT J
15170 NEXT I
15180 PRINT CHR$(4);"CLOSE";F$

15181 REM 
15182 PRINT CHR$(4);"READ";F$+".INDEX"
15183 INPUT X1:INPUT Y1:INPUT X9:INPUT Y9:INPUT V8:INPUT V9:INPUT G1:INPUT M(1):INPUT M(2):INPUT M(3):INPUT M(4):INPUT M(5):INPUT M(6):INPUT M(7):INPUT M(8):INPUT T$:INPUT MA
15184 PRINT CHR$(4);"CLOSE";F$+".INDEX"
15185 IF M(5)=0 THEN FOR I=1 TO 8:M(I)=I:NEXT I:T$="R  DR  D  DL  L  UL  U  UR "

15186 INVERSE:VTAB 23:HTAB 12:PRINT"                                                                    ":NORMAL
15187 GOSUB 15200


15188 REM

15189 NORMAL:VTAB 20:HTAB 45:PRINT"                     "
15190 LL=1:GOSUB 1200:P$=F$:GOTO 60

15200 BB=0:VTAB 20:HTAB 75:PRINT"    ":VTAB 21:HTAB 75:PRINT"   0":VTAB 22:HTAB 75:PRINT"   0" 
15202 FOR I=1 TO 19
15210 FOR J=1 TO 79
15220 IF B(I,J)=1 THEN VTAB I:HTAB J:PRINT"$":BB=BB+1:GOSUB 1200
15222 IF B(I,J)<>1 THEN VTAB I:HTAB J:PRINT" "
15230 NEXT J
15240 NEXT I
15250 RETURN


15500 NORMAL:VTAB 20:HTAB 45:PRINT"                     ":INVERSE:VTAB 23:HTAB 66:PRINT"             ":NORMAL

15502 FOR I=1 TO 19
15510 FOR J=1 TO 79
15520 VTAB I:HTAB J:PRINT" "
15530 NEXT J
15540 NEXT I

15542 FOR I=0 TO 20
15543 FOR J=0 TO 80
15544 B(I,J)=0
15545 NEXT J
15546 NEXT I

15547 FOR I=0 TO 1510:C(I)=0:NEXT I

15548 BB=0
15549 VTAB 20:HTAB 75:PRINT"   0":VTAB 21:HTAB 75:PRINT"   0":VTAB 22:HTAB 75:PRINT"   0"
15550 GOTO 60

15800 HOME
15802 PRINT CHR$(4);"CATALOG"+",D2,S6"
15810 PRINT:PRINT"<PRESS ANY KEY TO BE CONTINUE>":NORMAL:GET CT$:PRINT CT$
15820 HOME:BB=0
15830 FOR I=1 TO 19
15840 FOR J=1 TO 79
15850 IF B(I,J)=1 THEN VTAB I:HTAB J:PRINT"$":BB=BB+1
15860 NEXT J
15870 NEXT I

15880 IF D2=1 THEN D2=0:RETURN

15990 GOTO 52


22200 INVERSE:VTAB 23:HTAB 50:PRINT"ERROR OCCURED":NORMAL:FOR I=1 TO 50000:NEXT I:GOTO 60



24000 FOR I=1 TO 19
24010 FOR J=1 TO 79
24020 IF B(I,J)=1 THEN VTAB I:HTAB J:PRINT"$":GOTO 24040
24030 VTAB I:HTAB J:PRINT" "
24040 NEXT J
24050 NEXT I

24060 RETURN

27000 S1=S1+1:N1=21:N2=78
27010 IF S1>9 THEN N2=N2-1
27020 IF S1>99 THEN N2=N2-1
27030 IF S1>999 THEN N2=N2-1
27040 VTAB N1:HTAB N2: PRINT S1
27050 RETURN


28000 REM 
28010 IF B(X1,Y1)=1 THEN NORMAL:VTAB X1:HTAB Y1:PRINT"$"
28020 IF B(X1,Y1)=0 THEN NORMAL:VTAB X1:HTAB Y1:PRINT" "
28030 REM 
28040 INVERSE:VTAB X2:HTAB Y2:PRINT"$":NORMAL
 
28042 IF SP=1 THEN GOSUB 42310 

28050 RETURN

 





29000 IF X1=10 AND Y1=40 THEN 29040
29010 IF B(X1,Y1)=1 THEN NORMAL:VTAB X1:HTAB Y1:PRINT"$"
29020 IF B(X1,Y1)=0 THEN NORMAL:VTAB X1:HTAB Y1:PRINT" "
29030 IF X2=10 AND Y2=40 THEN 29050
29040 INVERSE:VTAB X2:HTAB Y2:PRINT"$":NORMAL
 

29050 RETURN


30000 REM 

30002 INVERSE:VTAB 23:HTAB 1:PRINT"COMMAND :                                                                     ":VTAB 23:HTAB 50:PRINT"MAZE GAME  ":VTAB 23:HTAB 11:GET A$:GOSUB 60000:VTAB 23:HTAB 11:PRINT A$:NORMAL

30010 IF A$="P" THEN X2=10:Y2=42:GOTO 31000
30020 IF A$="W" THEN X2=X1:Y2=Y1:GOTO 41000

30040 IF A$=CHR$(43) THEN INVERSE:VTAB 23:HTAB 12:PRINT"                                                                    ":NORMAL:GOTO 60

30060 GOTO 30002

31000 VTAB 10:HTAB 40:PRINT"M":INVERSE:VTAB X1:HTAB Y1:PRINT"$":NORMAL


31002 INVERSE:VTAB 23:HTAB 1:PRINT"COMMAND :                                                                     ":VTAB 23:HTAB 50:PRINT"PUZZLE":VTAB 23:HTAB 11:GET A$:GOSUB 60000:VTAB 23:HTAB 11:PRINT A$:NORMAL

31070 IF A$=CHR$(43) THEN INVERSE:VTAB X1:HTAB Y1:PRINT"$":NORMAL:VTAB 10:HTAB 40:PRINT"M":INVERSE:VTAB 23:HTAB 12:PRINT"                                                                    ":NORMAL:GOTO 30002

31076 IF A$="C" THEN NORMAL:VTAB 10:HTAB 40:PRINT" ":GOSUB 31100:F$="PUZZLE-TEMP":TM=1:CC=1:GOSUB 15010:GOSUB 62300:GOTO 32000

31080 IF A$="B" THEN NORMAL:VTAB 10:HTAB 40:PRINT" ":GOSUB 31100:F$="PUZZLE-TEMP":TM=1:GOSUB 15010:GOSUB 50000:GOTO 32000

31090 GOTO 31000


31100 IF B(X1,Y1)=1 THEN NORMAL:VTAB X1:HTAB Y1:PRINT"$"
31110 IF B(X1,Y1)=0 THEN NORMAL:VTAB X1:HTAB Y1:PRINT" "

31120 RETURN



32000 GD=0:CT=0

32010 INVERSE:VTAB 23:HTAB 11:GET A$:GOSUB 60000:VTAB 23:HTAB 11:PRINT A$:NORMAL

32070 IF A$=CHR$(43) THEN GD=0:PA=0:SP=0:TW=0:CT=0:WA=0:VW=0:F$="PUZZLE-TEMP":GOTO 15110

32072 IF A$="I" THEN GOSUB 52000:GOSUB 57000
32073 IF A$="J" THEN GOSUB 55000:GOSUB 57000
32074 IF A$="K" THEN GOSUB 54000:GOSUB 57000
32075 IF A$="M" THEN GOSUB 53000:GOSUB 57000

32076 IF A$="P" AND GD=1 THEN GOSUB 40000:GOSUB 57000

32077 IF A$="S" THEN PA=1:GOSUB 15000
32078 IF A$="Q" THEN GOTO 62200
32079 IF A$="G" THEN GD=GD+1:GOSUB 56000


32080 GOTO 32010


33000 INVERSE:VTAB 23:HTAB 1:PRINT"                                                                              ":VTAB 23:HTAB 50:PRINT"MAZE FIXING":VTAB 23:HTAB 1:INPUT"FILENAME : ";F$:NORMAL


33002 IF F$=CHR$(43) THEN INVERSE:VTAB 23:HTAB 12:PRINT"                                                                    ":NORMAL:GOTO 60

33010 A9=10:B9=40:C8=10:D9=38:E1=0:FF=1

33012 N(1)=1:N(2)=2:N(3)=3:N(4)=4:N(5)=5:N(6)=6:N(7)=7:N(8)=8

33014 H$="R  DR  D  DL  L  UL  U  UR "


33081 REM
33082 PRINT CHR$(4);"READ";F$+".INDEX"
33083 INPUT T1:INPUT T2
33084 PRINT CHR$(4);"CLOSE";F$+".INDEX"


33181 PRINT CHR$(4);"OPEN";F$+".INDEX"
33182 PRINT CHR$(4);"WRITE";F$+".INDEX"
33183 PRINT T1:PRINT T2:PRINT A9:PRINT B9:PRINT C8:PRINT D9:PRINT E1:PRINT N(1):PRINT N(2):PRINT N(3):PRINT N(4):PRINT N(5):PRINT N(6):PRINT N(7):PRINT N(8):PRINT H$:PRINT FF
33184 PRINT CHR$(4);"CLOSE";F$+".INDEX"

33186 INVERSE:VTAB 23:HTAB 50:PRINT"           ":VTAB 23:HTAB 12:PRINT"                              ":NORMAL

33190 GOTO 60








39000 IF X1=10 AND Y1=40 THEN 39040
39002 IF X1=XS AND Y1=YS THEN 39030
39010 IF B(X1,Y1)=1 THEN NORMAL:VTAB X1:HTAB Y1:PRINT"$"
39020 IF B(X1,Y1)=0 THEN NORMAL:VTAB X1:HTAB Y1:PRINT" "
39030 IF X2=10 AND Y2=40 THEN 39050
39040 INVERSE:VTAB X2:HTAB Y2:PRINT"$":NORMAL
 

39050 RETURN



40000 REM 
40020 PRINT CHR$(4);"READ PUZZLE-TANK" 
40030 FOR I=1 TO 6
40040 FOR J=1 TO 7
40050 INPUT W(I,J)
40060 NEXT J
40070 NEXT I
40072 PRINT CHR$(4);"CLOSE PUZZLE-TANK"


40100 FOR I=0 TO 5
40185 FOR J=0 TO 6


40188 B(XT+I,YT+J)=W(I+1,J+1)

40189 IF B(XT+I,YT+J)=1 THEN VTAB XT+I:HTAB YT+J:PRINT"$"
40190 IF B(XT+I,YT+J)=0 THEN VTAB XT+I:HTAB YT+J:PRINT" "

40196 NEXT J
40198 NEXT I

40199 GOSUB 49500

40200 RETURN


41000 SP=0:NORMAL:VTAB 10:HTAB 40:PRINT" "

41002 INVERSE:VTAB 23:HTAB 1:PRINT"COMMAND :                                                                     ":VTAB 23:HTAB 50:PRINT"SWAP":VTAB 23:HTAB 11:GET A$:GOSUB 60000:VTAB 23:HTAB 11:PRINT A$:NORMAL


41066 IF A$=CHR$(25) THEN X2=X1-1:Y2=Y1:GOSUB 1050:GOSUB 28000:X1=X2:Y1=Y2
41067 IF A$=CHR$(7) THEN X2=X1:Y2=Y1-1:GOSUB 1050:GOSUB 28000:X1=X2:Y1=Y2
41068 IF A$=CHR$(8) THEN X2=X1:Y2=Y1+1:GOSUB 1050:GOSUB 28000:X1=X2:Y1=Y2
41069 IF A$=CHR$(2) THEN X2=X1+1:Y2=Y1:GOSUB 1050:GOSUB 28000:X1=X2:Y1=Y2

41070 IF A$=CHR$(43) THEN INVERSE:VTAB X1:HTAB Y1:PRINT"$":NORMAL:VTAB 10:HTAB 40:PRINT"M":INVERSE:VTAB 23:HTAB 12:PRINT"                                                                    ":NORMAL:GOTO 30002

41080 IF A$="B" THEN SP=SP+1:GOSUB 42000:INVERSE:VTAB X1:HTAB Y1:PRINT"$":NORMAL

41090 GOTO 41002


42000 IF X2<7 AND X2>0 AND Y2<9 AND Y2>1 THEN SD=1
42010 IF X2<7 AND X2>0 AND Y2<16 AND Y2>8 THEN SD=2
42020 IF X2<7 AND X2>0 AND Y2<23 AND Y2>15 THEN SD=3
42030 IF X2<7 AND X2>0 AND Y2<30 AND Y2>22 THEN SD=4
42040 IF X2<7 AND X2>0 AND Y2<37 AND Y2>29 THEN SD=5
42050 IF X2<7 AND X2>0 AND Y2<44 AND Y2>36 THEN SD=6
42060 IF X2<7 AND X2>0 AND Y2<51 AND Y2>43 THEN SD=7
42070 IF X2<7 AND X2>0 AND Y2<58 AND Y2>50 THEN SD=8
42080 IF X2<7 AND X2>0 AND Y2<65 AND Y2>57 THEN SD=9
42090 IF X2<7 AND X2>0 AND Y2<72 AND Y2>64 THEN SD=10
42096 IF X2<7 AND X2>0 AND Y2<79 AND Y2>71 THEN SD=11


42100 IF X2<13 AND X2>6 AND Y2<9 AND Y2>1 THEN SD=12
42110 IF X2<13 AND X2>6 AND Y2<16 AND Y2>8 THEN SD=13
42120 IF X2<13 AND X2>6 AND Y2<23 AND Y2>15 THEN SD=14
42130 IF X2<13 AND X2>6 AND Y2<30 AND Y2>22 THEN SD=15
42140 IF X2<13 AND X2>6 AND Y2<37 AND Y2>29 THEN SD=16
42150 IF X2<13 AND X2>6 AND Y2<44 AND Y2>36 THEN SD=17
42160 IF X2<13 AND X2>6 AND Y2<51 AND Y2>43 THEN SD=18
42170 IF X2<13 AND X2>6 AND Y2<58 AND Y2>50 THEN SD=19
42180 IF X2<13 AND X2>6 AND Y2<65 AND Y2>57 THEN SD=20
42190 IF X2<13 AND X2>6 AND Y2<72 AND Y2>64 THEN SD=21
42196 IF X2<13 AND X2>6 AND Y2<79 AND Y2>71 THEN SD=22



42200 IF X2<19 AND X2>12 AND Y2<9 AND Y2>1 THEN SD=23
42210 IF X2<19 AND X2>12 AND Y2<16 AND Y2>8 THEN SD=24
42220 IF X2<19 AND X2>12 AND Y2<23 AND Y2>15 THEN SD=25
42230 IF X2<19 AND X2>12 AND Y2<30 AND Y2>22 THEN SD=26
42240 IF X2<19 AND X2>12 AND Y2<37 AND Y2>29 THEN SD=27
42250 IF X2<19 AND X2>12 AND Y2<44 AND Y2>36 THEN SD=28
42260 IF X2<19 AND X2>12 AND Y2<51 AND Y2>43 THEN SD=29
42270 IF X2<19 AND X2>12 AND Y2<58 AND Y2>50 THEN SD=30
42280 IF X2<19 AND X2>12 AND Y2<65 AND Y2>57 THEN SD=31
42290 IF X2<19 AND X2>12 AND Y2<72 AND Y2>64 THEN SD=32
42296 IF X2<19 AND X2>12 AND Y2<79 AND Y2>71 THEN SD=33

42300 GOSUB 61400

42302 IF SP=1 THEN XT=XR:YT=YR
42304 IF SP=2 THEN XV=XR:YV=YR


42310 INVERSE

42320 FOR I=XR TO XS
42322 VTAB I:HTAB YR:PRINT" "
42324 VTAB I:HTAB YS:PRINT" "

42325 IF X2=I THEN L8=1

42326 NEXT I

42330 FOR J=YR TO YS
42332 VTAB XR:HTAB J:PRINT" "
42334 VTAB XS:HTAB J:PRINT" "

42335 IF Y2=J THEN L9=1

42336 NEXT J

42338 IF L8=1 AND L9=1 THEN L8=0:L9=0:INVERSE:VTAB X2:HTAB Y2:PRINT"$":NORMAL

42340 NORMAL

42341 IF SP=2 THEN FOR L=1 TO 10000:NEXT L:GOSUB 51300:GOSUB 15200

42342 RETURN

48000 GOSUB 1000:GOSUB 29000:X1=X2:Y1=Y2
48010 RETURN

48100 GOSUB 1000:INVERSE:VTAB X2:HTAB Y2:PRINT"$":NORMAL:VTAB X1:HTAB Y1:PRINT"$":GOSUB 1100:B(X1,Y1)=1:GOSUB 1200:X1=X2:Y1=Y2
48110 RETURN

48200 GOSUB 1000:INVERSE:VTAB X2:HTAB Y2:PRINT"$":NORMAL:VTAB X1:HTAB Y1:PRINT" ":GOSUB 1150:B(X1,Y1)=0:GOSUB 1200:X1=X2:Y1=Y2
48210 RETURN


49000 FOR I=1 TO 19
49010 FOR J=1 TO 79
49020 IF B(I,J)=1 THEN VTAB I:HTAB J:PRINT"$":GOTO 49040
49030 VTAB I:HTAB J:PRINT" "
49040 NEXT J
49050 NEXT I
49060 RETURN

49500 BB=0

49502 FOR I=1 TO 19
49510 FOR J=1 TO 79
49520 IF B(I,J)=1 THEN BB=BB+1
49530 NEXT J
49540 NEXT I

49542 GOSUB 1200

49550 RETURN


50000 FOR I=0 TO 6
50010 FOR J=0 TO 7
50020 W(I,J)=0
50030 NEXT J
50040 NEXT I
 


51266 FOR K=1 TO 100


51270 GOSUB 59000
51272 SD=INT(RND(RR)*33+1)
51274 GOSUB 61400
51276 XT=XR:YT=YR:XU=XS:YU=YS

51280 GOSUB 59000
51282 SD=INT(RND(RR)*33+1)
51284 GOSUB 61400
51286 XV=XR:YV=YR:XW=XS:YW=YS

51300 REM 


51302 FOR I=0 TO 5
51304 FOR J=0 TO 6

51310 W(0,0)=B(XT+I,YT+J):B(XT+I,YT+J)=B(XV+I,YV+J):B(XV+I,YV+J)=W(0,0)

51312 IF B(XT+I,YT+J)=1 THEN VTAB XT+I:HTAB YT+J:PRINT"$"
51313 IF B(XT+I,YT+J)=0 THEN VTAB XT+I:HTAB YT+J:PRINT" " 
51314 IF B(XV+I,YV+J)=1 THEN VTAB XV+I:HTAB YV+J:PRINT"$"
51315 IF B(XV+I,YV+J)=0 THEN VTAB XV+I:HTAB YV+J:PRINT" "

51317 NEXT J
51318 NEXT I

51319 IF TW=1 THEN RETURN
51320 IF SP=2 THEN SP=0:RETURN

51328 NEXT K


51330 GOSUB 61700

51332 RETURN



52000 REM 

52002 IF SD>22 THEN RETURN

52004 GOSUB 58000

52006 GOSUB 61400
52010 XT=XR:YT=YR:XU=XS:YU=YS
52020 SD=SD+11
52030 GOSUB 61400
52040 XV=XR:YV=YR:XW=XS:YW=YS
52050 TW=1:GOSUB 51300
52052 XT=XV:YT=YV

52054 IF GD=1 THEN GOSUB 61784:RETURN

52060 WA=1:GOSUB 61700:WA=0

52070 RETURN


53000 REM 

53002 IF SD<12 THEN RETURN

53004 GOSUB 58000

53006 GOSUB 61400
53010 XT=XR:YT=YR:XU=XS:YU=YS
53020 SD=SD-11
53030 GOSUB 61400
53040 XV=XR:YV=YR:XW=XS:YW=YS
53050 TW=1:GOSUB 51300
53052 XT=XV:YT=YV

53054 IF GD=1 THEN GOSUB 61784:RETURN

53060 WA=1:GOSUB 61700:WA=0

53070 RETURN


54000 REM 

54002 IF SD=1 OR SD=12 OR SD=23 THEN RETURN

54004 GOSUB 58000

54006 GOSUB 61400
54010 XT=XR:YT=YR:XU=XS:YU=YS
54020 SD=SD-1
54030 GOSUB 61400
54040 XV=XR:YV=YR:XW=XS:YW=YS
54050 TW=1:GOSUB 51300
54052 XT=XV:YT=YV

54054 IF GD=1 THEN GOSUB 61784:RETURN

54060 WA=1:GOSUB 61700:WA=0

54070 RETURN



55000 REM 

55002 IF SD=11 OR SD=22 OR SD=33 THEN RETURN

55004 GOSUB 58000

55006 GOSUB 61400
55010 XT=XR:YT=YR:XU=XS:YU=YS
55020 SD=SD+1
55030 GOSUB 61400
55040 XV=XR:YV=YR:XW=XS:YW=YS
55050 TW=1:GOSUB 51300
55052 XT=XV:YT=YV

55054 IF GD=1 THEN GOSUB 61784:RETURN

55060 WA=1:GOSUB 61700:WA=0

55070 RETURN


56000 IF GD=1 THEN GOSUB 15200:GOSUB 57000:RETURN
56010 IF GD=2 THEN GOSUB 61700:GD=0:RETURN


57000 INVERSE

57002 FOR I=0 TO 5
57020 VTAB XT+I:HTAB YT:PRINT" "
57030 VTAB XT+I:HTAB YT+6:PRINT" "
57040 NEXT I

57050 FOR J=0 TO 6
57060 VTAB XT:HTAB YT+J:PRINT" "
57070 VTAB XT+5:HTAB YT+J:PRINT" "
57080 NEXT J

57082 NORMAL

57090 RETURN


58000 CT=CT+1
58010 INVERSE:VTAB 23:HTAB 66:PRINT"MOVE : ";CT:NORMAL
58020 RETURN




59000 FOR I=1 TO RR
59001 TE=RND(RR)
59002 NEXT I

59003 RR=TE

59010 RETURN

60000 IF A$=CHR$(10) OR A$=CHR$(13) OR A$=CHR$(22) OR A$=CHR$(12) OR A$=CHR$(11) OR A$=CHR$(17) OR A$=CHR$(23) OR A$=CHR$(21) OR A$=CHR$(27) THEN A$=" "
60002 RETURN
   


61400 IF SD=1 THEN LN=1:XR=1:YR=2:XS=6:YS=8
61410 IF SD=2 THEN LN=1:XR=1:YR=9:XS=6:YS=15
61420 IF SD=3 THEN LN=1:XR=1:YR=16:XS=6:YS=22
61430 IF SD=4 THEN LN=1:XR=1:YR=23:XS=6:YS=29
61440 IF SD=5 THEN LN=1:XR=1:YR=30:XS=6:YS=36
61450 IF SD=6 THEN LN=1:XR=1:YR=37:XS=6:YS=43
61460 IF SD=7 THEN LN=1:XR=1:YR=44:XS=6:YS=50
61470 IF SD=8 THEN LN=1:XR=1:YR=51:XS=6:YS=57
61480 IF SD=9 THEN LN=1:XR=1:YR=58:XS=6:YS=64
61490 IF SD=10 THEN LN=1:XR=1:YR=65:XS=6:YS=71
61496 IF SD=11 THEN LN=1:XR=1:YR=72:XS=6:YS=78

61500 IF SD=12 THEN LN=2:XR=7:YR=2:XS=12:YS=8
61510 IF SD=13 THEN LN=2:XR=7:YR=9:XS=12:YS=15
61520 IF SD=14 THEN LN=2:XR=7:YR=16:XS=12:YS=22
61530 IF SD=15 THEN LN=2:XR=7:YR=23:XS=12:YS=29
61540 IF SD=16 THEN LN=2:XR=7:YR=30:XS=12:YS=36
61550 IF SD=17 THEN LN=2:XR=7:YR=37:XS=12:YS=43
61560 IF SD=18 THEN LN=2:XR=7:YR=44:XS=12:YS=50
61570 IF SD=19 THEN LN=2:XR=7:YR=51:XS=12:YS=57
61580 IF SD=20 THEN LN=2:XR=7:YR=58:XS=12:YS=64
61590 IF SD=21 THEN LN=2:XR=7:YR=65:XS=12:YS=71
61596 IF SD=22 THEN LN=2:XR=7:YR=72:XS=12:YS=78

61600 IF SD=23 THEN LN=3:XR=13:YR=2:XS=18:YS=8
61610 IF SD=24 THEN LN=3:XR=13:YR=9:XS=18:YS=15
61620 IF SD=25 THEN LN=3:XR=13:YR=16:XS=18:YS=22
61630 IF SD=26 THEN LN=3:XR=13:YR=23:XS=18:YS=29
61640 IF SD=27 THEN LN=3:XR=13:YR=30:XS=18:YS=36
61650 IF SD=28 THEN LN=3:XR=13:YR=37:XS=18:YS=43
61660 IF SD=29 THEN LN=3:XR=13:YR=44:XS=18:YS=50
61670 IF SD=30 THEN LN=3:XR=13:YR=51:XS=18:YS=57
61680 IF SD=31 THEN LN=3:XR=13:YR=58:XS=18:YS=64
61690 IF SD=32 THEN LN=3:XR=13:YR=65:XS=18:YS=71
61696 IF SD=33 THEN LN=3:XR=13:YR=72:XS=18:YS=78

61697 TD=SD

61698 RETURN


61700 INVERSE

61710 FOR I=1 TO 19
61720 FOR J=2 TO 79 STEP 7
61730 VTAB I:HTAB J:PRINT" "
61740 NEXT J
61750 NEXT I
 

61760 FOR I=1 TO 19 STEP 6
61761 FOR J=2 TO 79 
61762 VTAB I:HTAB J:PRINT" "
61764 NEXT J
61766 NEXT I

61768 IF CT=1 OR GD=2 OR WA=1 THEN 61780

 
61770 GOSUB 59000
61772 SD=INT(RND(RR)*33+1)
61774 GOSUB 61400
61776 XT=XR:YT=YR:XU=XS:YU=YS

61780 INVERSE

61784 FOR I=0 TO 5
61785 FOR J=0 TO 6


61787 IF TW=1 OR GD>0 OR CT=1 THEN 61789

61788 VV=1:W(I+1,J+1)=B(XT+I,YT+J)

61789 VTAB XT+I:HTAB YT+J:PRINT" ":B(XT+I,YT+J)=0

61790 NEXT J
61791 NEXT I

61792 IF TW=1 THEN TW=0:GOTO 61797
61793 IF GD>0 THEN GD=0:GOTO 61797
61794 IF CT=1 THEN CT=0:GOTO 61797



61796 VW=1:GOSUB 62000

61797 NORMAL

61798 RETURN

62000 REM 
62002 PRINT CHR$(4);"OPEN PUZZLE-TANK"
62020 PRINT CHR$(4);"WRITE PUZZLE-TANK" 
62030 FOR I=1 TO 6
62040 FOR J=1 TO 7
62050 PRINT W(I,J)
62060 NEXT J
62070 NEXT I
62072 PRINT CHR$(4);"CLOSE PUZZLE-TANK"

62074 RETURN

62200 REM 
62202 PRINT CHR$(4);"OPEN PUZZLE-CONTINUE"
62220 PRINT CHR$(4);"WRITE PUZZLE-CONTINUE" 
62230 FOR I=1 TO 19
62240 FOR J=1 TO 79
62250 PRINT B(I,J)
62260 NEXT J
62270 NEXT I
62272 PRINT CHR$(4);"CLOSE PUZZLE-CONTINUE"


62280 PRINT CHR$(4);"OPEN PUZZLE-CONTINUE.INDEX"
62282 PRINT CHR$(4);"WRITE PUZZLE-CONTINUE.INDEX" 

62284 PRINT SD:PRINT XR:PRINT YR:PRINT XS:PRINT YS:PRINT XT:PRINT YT:PRINT XU:PRINT YU:PRINT XV:PRINT YV:PRINT XW:PRINT YW

62286 PRINT CHR$(4);"CLOSE PUZZLE-CONTINUE.INDEX"



62288 PRINT CHR$(4);"OPEN PUZZLE-CONTINUE.TANK"
62289 PRINT CHR$(4);"WRITE PUZZLE-CONTINUE.TANK" 

62290 FOR I=1 TO 6
62291 FOR J=1 TO 7
62292 PRINT W(I,J)
62293 NEXT J
62294 NEXT I


62296 PRINT CHR$(4);"CLOSE PUZZLE-CONTINUE.TANK"


62298 F$="PUZZLE-TEMP":GOTO 15110



62300 REM 
62320 PRINT CHR$(4);"READ PUZZLE-CONTINUE" 
62330 FOR I=1 TO 19
62340 FOR J=1 TO 79
62350 INPUT B(I,J)
62360 NEXT J
62370 NEXT I
62372 PRINT CHR$(4);"CLOSE PUZZLE-CONTINUE"


62380 REM 
62382 PRINT CHR$(4);"READ PUZZLE-CONTINUE.INDEX" 

62384 INPUT SD:INPUT XR:INPUT YR:INPUT XS:INPUT YS:INPUT XT:INPUT YT:INPUT XU:INPUT YU:INPUT XV:INPUT YV:INPUT XW:INPUT YW

62386 PRINT CHR$(4);"CLOSE PUZZLE-CONTINUE.INDEX"


62388 REM 
62389 PRINT CHR$(4);"READ PUZZLE-CONTINUE.TANK" 

62390 FOR I=1 TO 6
62391 FOR J=1 TO 7
62392 INPUT W(I,J)
62393 NEXT J
62394 NEXT I


62395 PRINT CHR$(4);"CLOSE PUZZLE-CONTINUE.TANK"


62396 GOSUB 15200 

62397 CT=1:GOSUB 61700:CT=0

62398 RETURN














